using Lzfy_His_Service.Models;

namespace Lzfy_His_Service.Services
{
    /// <summary>
    /// 企业微信服务接口
    /// </summary>
    public interface IWeChatWorkService
    {
        /// <summary>
        /// 获取企业微信授权URL
        /// </summary>
        /// <param name="redirectUri">回调URL</param>
        /// <param name="state">状态参数</param>
        /// <returns>授权URL响应</returns>
        Task<WeChatWorkAuthUrlResponse> GetAuthUrlAsync(string? redirectUri = null, string? state = null);

        /// <summary>
        /// 通过授权码获取用户信息
        /// </summary>
        /// <param name="code">授权码</param>
        /// <returns>用户信息</returns>
        Task<WeChatWorkUserInfo?> GetUserInfoByCodeAsync(string code);

        /// <summary>
        /// 企业微信登录
        /// </summary>
        /// <param name="code">授权码</param>
        /// <param name="state">状态参数</param>
        /// <returns>登录响应</returns>
        Task<WeChatWorkLoginResponse> LoginAsync(string code, string? state = null);

        /// <summary>
        /// 验证企业微信用户是否有效
        /// </summary>
        /// <param name="userId">用户ID</param>
        /// <returns>是否有效</returns>
        Task<bool> ValidateUserAsync(string userId);

        /// <summary>
        /// 生成JWT Token
        /// </summary>
        /// <param name="userInfo">用户信息</param>
        /// <returns>JWT Token</returns>
        string GenerateJwtToken(WeChatWorkUserInfo userInfo);

        /// <summary>
        /// 通过企业微信用户ID查询用户名
        /// </summary>
        /// <param name="wxUserId">企业微信用户ID</param>
        /// <returns>用户名查询结果</returns>
        Task<WeChatWorkUsernameResponse> GetUsernameByWxUserIdAsync(string wxUserId);

        /// <summary>
        /// 通过用户名获取用户详细信息
        /// </summary>
        /// <param name="username">用户名</param>
        /// <returns>用户详细信息</returns>
        Task<WeChatWorkUserDetailResponse> GetUserDetailByUsernameAsync(string username);

        /// <summary>
        /// 发送企业微信消息
        /// </summary>
        /// <param name="request">消息推送请求</param>
        /// <returns>消息推送响应</returns>
        Task<WeChatWorkMessageResponse> SendMessageAsync(WeChatWorkMessageRequest request);

        /// <summary>
        /// 获取企业微信Access Token
        /// </summary>
        /// <returns>Access Token</returns>
        Task<string?> GetAccessTokenAsync();

        /// <summary>
        /// 发送文本消息
        /// </summary>
        /// <param name="userId">用户ID</param>
        /// <param name="content">消息内容</param>
        /// <returns>发送结果</returns>
        Task<WeChatWorkMessageResponse> SendTextMessageAsync(string userId, string content);

        /// <summary>
        /// 发送文本卡片消息
        /// </summary>
        /// <param name="userId">用户ID</param>
        /// <param name="title">标题</param>
        /// <param name="description">描述</param>
        /// <param name="url">跳转链接</param>
        /// <param name="btnTxt">按钮文字</param>
        /// <returns>发送结果</returns>
        Task<WeChatWorkMessageResponse> SendTextCardMessageAsync(string userId, string title, string description, string url, string btnTxt = "详情");

        /// <summary>
        /// 发送Markdown消息
        /// </summary>
        /// <param name="userId">用户ID</param>
        /// <param name="content">Markdown内容</param>
        /// <returns>发送结果</returns>
        Task<WeChatWorkMessageResponse> SendMarkdownMessageAsync(string userId, string content);
    }
}